package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.model.enums.ActivityEnum;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_ACTIVITY_INFO")
public class ActivityInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "投诉转办流程活动信息";
	public static final String ALIAS_ACTIVITY_INFO_ID = "activityInfoId";
	public static final String ALIAS_TSZB_PROCESS_INFO_ID = "tszbProcessInfoId";
	public static final String ALIAS_USER_INFO_ID = "userInfoId";
	public static final String ALIAS_OPERATOR_NAME = "办理人姓名";
	public static final String ALIAS_RECEIVE_TIME = "接收时间";
	public static final String ALIAS_FINISH_TIME = "办结时间";
	public static final String ALIAS_OPIN = "办理意见";
	public static final String ALIAS_ACTIVITY_NAME = "活动名称";
	public static final String ALIAS_ACTIVITY_INST_ID = "活动实例ID";
	public static final String ALIAS_INCOMING_CALL_CONTENT = "来电内容";
	public static final String ALIAS_INCOMING_CALL_CONTENT_BAK = "incomingCallContentBak";

	//date formats
	public static final String FORMAT_RECEIVE_TIME = DATE_TIME_FORMAT;
	public static final String FORMAT_FINISH_TIME = DATE_TIME_FORMAT;


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * activityInfoId       db_column: ACTIVITY_INFO_ID
     */
	
	private Long activityInfoId;
    /**
     * tszbProcessInfoId       db_column: TSZB_PROCESS_INFO_ID
     */
	
	private Long tszbProcessInfoId;
    /**
     * userInfoId       db_column: USER_INFO_ID
     */
	
	private Long userInfoId;
    /**
     * 办理人姓名       db_column: OPERATOR_NAME
     */
	@Length(max=100)
	private java.lang.String operatorName;
    /**
     * 接收时间       db_column: RECEIVE_TIME
     */
	
	private java.util.Date receiveTime;
    /**
     * 办结时间       db_column: FINISH_TIME
     */
	
	private java.util.Date finishTime;
    /**
     * 办理意见       db_column: OPIN
     */
	@Length(max=1000)
	private java.lang.String opin;
    /**
     * 活动名称       db_column: ACTIVITY_NAME
     */
	@Length(max=100)
	private java.lang.String activityName;
    /**
     * 活动实例ID       db_column: ACTIVITY_INST_ID
     */
	
	private Long activityInstId;
    /**
     * 来电内容       db_column: INCOMING_CALL_CONTENT
     */
	@Length(max=4000)
	private java.lang.String incomingCallContent;
    /**
     * incomingCallContentBak       db_column: INCOMING_CALL_CONTENT_BAK
     */
	@Length(max=4000)
	private java.lang.String incomingCallContentBak;
	//columns END


	public ActivityInfo(){
	}

	public ActivityInfo(
		Long activityInfoId
	){
		this.activityInfoId = activityInfoId;
	}



	public void setActivityInfoId(Long value) {
		this.activityInfoId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_ACTIVITY_INFO_SEQU")
    @SequenceGenerator(name="BJ12320_ACTIVITY_INFO_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_ACTIVITY_INFO_SEQU")
	@Column(name = "ACTIVITY_INFO_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 0)
	public Long getActivityInfoId() {
		return this.activityInfoId;
	}

	@Column(name = "TSZB_PROCESS_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getTszbProcessInfoId() {
		return this.tszbProcessInfoId;
	}

	public void setTszbProcessInfoId(Long value) {
		this.tszbProcessInfoId = value;
	}

	@Column(name = "USER_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	public void setUserInfoId(Long value) {
		this.userInfoId = value;
	}

	@Column(name = "OPERATOR_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getOperatorName() {
		return this.operatorName;
	}

	public void setOperatorName(java.lang.String value) {
		this.operatorName = value;
	}

	@Transient
	public String getReceiveTimeString() {
		return DateConvertUtils.format(getReceiveTime(), FORMAT_RECEIVE_TIME);
	}
	public void setReceiveTimeString(String value) {
		setReceiveTime(DateConvertUtils.parse(value, FORMAT_RECEIVE_TIME,java.util.Date.class));
	}

	@Column(name = "RECEIVE_TIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getReceiveTime() {
		return this.receiveTime;
	}

	public void setReceiveTime(java.util.Date value) {
		this.receiveTime = value;
	}

	@Transient
	public String getFinishTimeString() {
		return DateConvertUtils.format(getFinishTime(), FORMAT_FINISH_TIME);
	}
	public void setFinishTimeString(String value) {
		setFinishTime(DateConvertUtils.parse(value, FORMAT_FINISH_TIME,java.util.Date.class));
	}

	@Column(name = "FINISH_TIME", unique = false, nullable = true, insertable = true, updatable = true, length = 7)
	public java.util.Date getFinishTime() {
		return this.finishTime;
	}

	public void setFinishTime(java.util.Date value) {
		this.finishTime = value;
	}

	@Column(name = "OPIN", unique = false, nullable = true, insertable = true, updatable = true, length = 1000)
	public java.lang.String getOpin() {
		return this.opin;
	}

	public void setOpin(java.lang.String value) {
		this.opin = value;
	}

	@Column(name = "ACTIVITY_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getActivityName() {
		return this.activityName;
	}

	public void setActivityName(java.lang.String value) {
		this.activityName = value;
	}

	@Column(name = "ACTIVITY_INST_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getActivityInstId() {
		return this.activityInstId;
	}

	public void setActivityInstId(Long value) {
		this.activityInstId = value;
	}

	@Column(name = "INCOMING_CALL_CONTENT", unique = false, nullable = true, insertable = true, updatable = true, length = 4000)
	public java.lang.String getIncomingCallContent() {
		return this.incomingCallContent;
	}

	public void setIncomingCallContent(java.lang.String value) {
		this.incomingCallContent = value;
	}

	@Column(name = "INCOMING_CALL_CONTENT_BAK", unique = false, nullable = true, insertable = true, updatable = true, length = 4000)
	public java.lang.String getIncomingCallContentBak() {
		return this.incomingCallContentBak;
	}

	public void setIncomingCallContentBak(java.lang.String value) {
		this.incomingCallContentBak = value;
	}


	private Set gradeItems = new HashSet(0);
	public void setGradeItems(Set<GradeItem> gradeItem){
		this.gradeItems = gradeItem;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "activityInfo")
	public Set<GradeItem> getGradeItems() {
		return gradeItems;
	}

	private TszbProcessInfo tszbProcessInfo;
	public void setTszbProcessInfo(TszbProcessInfo tszbProcessInfo){
		this.tszbProcessInfo = tszbProcessInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "TSZB_PROCESS_INFO_ID",nullable = false, insertable = false, updatable = false) 
	})
	public TszbProcessInfo getTszbProcessInfo() {
		return tszbProcessInfo;
	}

	private UserInfo userInfo;
	public void setUserInfo(UserInfo userInfo){
		this.userInfo = userInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "USER_INFO_ID",nullable = false, insertable = false, updatable = false) 
	})
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("ActivityInfoId",getActivityInfoId())
			.append("TszbProcessInfoId",getTszbProcessInfoId())
			.append("UserInfoId",getUserInfoId())
			.append("OperatorName",getOperatorName())
			.append("ReceiveTime",getReceiveTime())
			.append("FinishTime",getFinishTime())
			.append("Opin",getOpin())
			.append("ActivityName",getActivityName())
			.append("ActivityInstId",getActivityInstId())
			.append("IncomingCallContent",getIncomingCallContent())
			.append("IncomingCallContentBak",getIncomingCallContentBak())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getActivityInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof ActivityInfo == false) return false;
		if(this == obj) return true;
		ActivityInfo other = (ActivityInfo)obj;
		return new EqualsBuilder()
			.append(getActivityInfoId(),other.getActivityInfoId())
			.isEquals();
	}

	@Transient
	public String getActivityNameString() {
		return activityName==null?"":ActivityEnum.getByCode(activityName).getDesc();
	}
}

